/**
 * 
 */
package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.dao.FinancialInstitutionDao;
import com.ap.core.domain.FinancialInstitution;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * @author Dilip.Sridhar
 * 
 */
public abstract class AbstractFICheckRule<T, OI> extends AbstractValidationRule<MessageValidationInfo<T, OI>> {

	protected FinancialInstitutionDao financialInstitutionDao;

	protected boolean isFinancialInstitutionExists(String fiId) {
		final FinancialInstitution financialInstitution = financialInstitutionDao.getFIByIdentification(fiId);
		return null != financialInstitution;
	}

	protected boolean isFinancialInstitutionActive(String fiId) {
		final FinancialInstitution financialInstitution = financialInstitutionDao.getFIByIdentification(fiId);
		return ActivationStatus.ACTIVE.name().equals(financialInstitution.getZappServiceStatus());
	}

	abstract public boolean validate(MessageValidationInfo<T, OI> infoObject);

	public void setFinancialInstitutionDao(
			FinancialInstitutionDao financialInstitutionDao) {
		this.financialInstitutionDao = financialInstitutionDao;
	}

}
